import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const Home = () => import('@/views/home/Home')
const Blog = () => import('@/views/blog/Blog')
const BlogArticleDetail = () => import('@/views/blog/childComps/detail/BlogArticleDetail')
const BlogArticles = () => import('@/views/blog/childComps/articles/BlogArticles')
const BlogEditorPage = () => import('@/views/blog/childComps/editor/BlogEditorPage')

const routes = [
  {
    path: '',
    redirect: '/home'
  },
  {
    path: '/home',
    component: Home
  },
  {
    path: '/blog',
    component: Blog,
    children: [
      {path: '', redirect: '/blog/articles'},
      {path: 'articles', component: BlogArticles},
      {path: 'article_detail/:article_id', component: BlogArticleDetail},
      {path: 'article_edit', component: BlogEditorPage},
      {path: 'article_edit/:article_id', component: BlogEditorPage},
    ]
  },
  {path: '/article_edit', component: BlogEditorPage},
  {path: '/article_edit/:article_id', component: BlogEditorPage},
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
